#!/bin/bash
#authors Eugeni Dodonov <edodonov@mandriva.com>, Stéphane Laurière <slauriere@mandriva.com>

VIRTUOSO_HOME=/var/lib/virtuoso/

 # loads bugs into virtuoso

if [ "a$1b$2" = "ab" ]; then
         echo "Usage: $0 <turtle file> <graph URI> <virtuoso-user> <virtuoso-user-password>"
         exit 1
fi

ISQL="$VIRTUOSO_HOME/bin/isql -U $3 -P $4"

# creating sql template
SQL=$(mktemp)
cat > $SQL << EOF
db.dba.ttlp(file_to_string_output('$1'), '', '$2', 1);
EOF

# now running isql
echo load \'$SQL\'\; | $ISQL

rm -f $SQL
